package com.ajie.slimming.db;
/**
 * 数据库表的列名称
 * @author 阿洁
 * 后期可能随时变化
 */
public class Column {
	private String name;
	private Type type;
	private boolean nullable = true;
	private boolean primaryKey = false;
	public static final String ID = "_id";
	
	
	
	
	public Column(String name, Type type){
		this.name = name;
		this.type = type;
	}
	
	public String getCreateString(){
		String createText = name +" " + type.typeStrng;
		if(!nullable){
			createText += " not null";
		}
		
		if(primaryKey){
			createText += " primary key";
		}
		return createText;
	}
	
	
	public String getName(){
		return name;
	}
	
	public Column setNullable(boolean nullable){
		this.nullable = nullable;
		return this;
	}
	
	public Column setPrimaryKey(boolean primaryKey){
		this.primaryKey = primaryKey;
		return this;
	}
	
	public enum Type{
		INTEGER("integer"),STRING("text"),FLOAT("real"),;
		private String typeStrng;
		 
		Type(String typeString){
			this.typeStrng = typeString;
		}
	}

}
